//
//  BusinessCompanyViewController.m
//  jingjing2.0
//
//  Created by apple on 16/5/18.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "BusinessWelfareViewController.h"
#import "WriteApplicationViewController.h"
@interface BusinessWelfareViewController ()
{
     CGFloat heightY;
     CGFloat height;
}

@end

@implementation BusinessWelfareViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    heightY=0;
    height=0;
    self.title=@"净净为企业助力";
    self.automaticallyAdjustsScrollViewInsets=NO;
    self.view.backgroundColor=[UIColor whiteColor];
    [self setUpBgScrollView];
    [self setUpButtomBtn];
}
#pragma mark--底部按钮
-(void)setUpButtomBtn
{
    UIButton *btn=[[UIButton alloc]initWithFrame:CGRectMake(0, kHeight-40, kWidth, 40)];
    btn.backgroundColor=[UIColor orangeColor];
    [btn setTitle:@"申请企业福利" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(clickOnBtn) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}
-(void)clickOnBtn
{
    WriteApplicationViewController *writeApplication=[[WriteApplicationViewController alloc]init];
    writeApplication.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:writeApplication animated:YES];
}
#pragma mark--滑动背景
-(void)setUpBgScrollView
{
    UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, kWidth, kHeight-64-40)];
    scrollView.backgroundColor=[UIColor whiteColor];
    scrollView.pagingEnabled=NO;
    [self.view addSubview:scrollView];
    
    for (int i=0; i<6; i++) {
        NSString *imagePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"main_%d",i+1] ofType:@"jpg"];
        UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];
        if (image.size.height>700) {
            height=600;
        }else
        {
            height=image.size.height-200;
        }

        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.frame = CGRectMake(0, heightY, kWidth, height);
        imageView.image=image;
        heightY+=height;
      [scrollView addSubview:imageView];
    }
    scrollView.contentSize=CGSizeMake(kWidth, heightY);
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [GeneralTool hideTabBar];
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [GeneralTool showTabBar];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
